'use strict'

module.exports = (app) => {
  const { INTEGER, DATE } = app.Sequelize
  // 配置（重要：一定要配置详细，一定要！！！）
  const RolePermissions = app.model.define('role_permissions', {
    id: {
      type: INTEGER(20).UNSIGNED,
      primaryKey: true,
      autoIncrement: true
    },
    rid: {
      type: INTEGER(20).UNSIGNED,
      comment: '角色id'
    },
    pid: {
      type: INTEGER(20).UNSIGNED,
      comment: '权限id'
    },
    created_time: {
      type: DATE,
      get() {
        return app.formatTime(this.getDataValue('created_time'))
      }
    }
  })
  // 关联关系

  return RolePermissions
}
